package com.ewater.shortlink.admin.controller;

import com.ewater.shortlink.admin.common.convention.result.Result;
import com.ewater.shortlink.admin.common.enums.UserErrorCodeEnum;
import com.ewater.shortlink.admin.dto.resp.UserDTO;
import com.ewater.shortlink.admin.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * 功能:用户管理控制层
 *
 */
@RestController
public class UserController {
    @Autowired
    private  UserService userService;

    /**
     *
     * @param username 根据用户名查用户信息
     * @return
     */
    @GetMapping("/api/shortlink/v1/user/{username}")
    public Result<UserDTO> getUserByUserName(@PathVariable("username") String username) {
        UserDTO result = userService.getUserByUsername(username);
        return new Result<UserDTO>().setCode(UserErrorCodeEnum.USER_EXIST.code()).setMessage(UserErrorCodeEnum.USER_EXIST.message()).setData(result);
    }

}
